<?php

/**
 * This is the model class for table "alarm_system".
 *
 * The followings are the available columns in table 'alarm_system':
 * @property integer $id
 * @property integer $fire_alarm_provided
 * @property string $type
 * @property integer $centralized
 * @property string $location_of_central_control
 * @property integer $no_of_bell_per_floor
 * @property string $bell_location
 * @property string $coverage
 * @property string $portion_specify
 * @property integer $monitored
 * @property string $type_of_intiation_device
 * @property string $toid_other
 * @property integer $no_of_pull_station_per_floor
 * @property integer $smoke_detector
 * @property integer $sd_no_of_unit_per_floor
 * @property integer $sd_integrated
 * @property integer $heat_detector
 * @property integer $hd_no_of_unit_per_room
 * @property integer $hd_integrated
 * @property string $power_source_of_detector
 * @property string $psod_other
 * @property integer $total_detector_per_floor
 * @property string $date_last_tested
 * @property integer $inspection_id
 *
 * The followings are the available model relations:
 * @property Inspection $inspection
 */
class AlarmSystem extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AlarmSystem the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

const a = "Manual";
const b ="Automatic";
public function getType(){
return array(
self::a=>"Manual",
self::b=>"Automatic"
);


}

const c = "Building";
const d = "Air Handling Unit";
const e = "Portion";
public function getCoverage(){
return array(
self::c=>"Building",
self::d=>"Air Handling Unit",
self::e=>"Portion"
);

}


const f = "AC/DC";
const g = "Others";

public function getPower_source_of_detector(){
return array(
self::f=>"AC/DC",
self::g=>"Others"

);

}


	
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'alarm_system';
		
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	 
	 
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('inspection_id', 'required'),
			array('fire_alarm_provided, centralized, no_of_bell_per_floor, monitored, no_of_pull_station_per_floor, smoke_detector, sd_no_of_unit_per_floor, sd_integrated, heat_detector, hd_no_of_unit_per_room, hd_integrated, total_detector_per_floor, inspection_id', 'numerical', 'integerOnly'=>true),
			array('type', 'length', 'max'=>9),
			array('coverage', 'length', 'max'=>17),
			array('power_source_of_detector', 'length', 'max'=>6),
			array('location_of_central_control, bell_location, portion_specify, type_of_intiation_device, toid_other, psod_other, date_last_tested', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, fire_alarm_provided, type, centralized, location_of_central_control, no_of_bell_per_floor, bell_location, coverage, portion_specify, monitored, type_of_intiation_device, toid_other, no_of_pull_station_per_floor, smoke_detector, sd_no_of_unit_per_floor, sd_integrated, heat_detector, hd_no_of_unit_per_room, hd_integrated, power_source_of_detector, psod_other, total_detector_per_floor, date_last_tested, inspection_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'inspection' => array(self::BELONGS_TO, 'Inspection', 'inspection_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'fire_alarm_provided' => 'Fire Alarm Provided',
			'type' => 'Type',
			'centralized' => 'Centralized',
			'location_of_central_control' => 'Location Of Central Control',
			'no_of_bell_per_floor' => 'No Of Bell Per Floor',
			'bell_location' => 'Bell Location',
			'coverage' => 'Coverage',
			'portion_specify' => 'Portion Specify',
			'monitored' => 'Monitored',
			'type_of_intiation_device' => 'Type Of Intiation Device',
			'toid_other' => 'Toid Other',
			'no_of_pull_station_per_floor' => 'No Of Pull Station Per Floor',
			'smoke_detector' => 'Smoke Detector',
			'sd_no_of_unit_per_floor' => 'Sd No Of Unit Per Floor',
			'sd_integrated' => 'Sd Integrated',
			'heat_detector' => 'Heat Detector',
			'hd_no_of_unit_per_room' => 'Hd No Of Unit Per Room',
			'hd_integrated' => 'Hd Integrated',
			'power_source_of_detector' => 'Power Source Of Detector',
			'psod_other' => 'Psod Other',
			'total_detector_per_floor' => 'Total Detector Per Floor',
			'date_last_tested' => 'Date Last Tested',
			'inspection_id' => 'Inspection',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('fire_alarm_provided',$this->fire_alarm_provided);
		$criteria->compare('type',$this->type,true);
		$criteria->compare('centralized',$this->centralized);
		$criteria->compare('location_of_central_control',$this->location_of_central_control,true);
		$criteria->compare('no_of_bell_per_floor',$this->no_of_bell_per_floor);
		$criteria->compare('bell_location',$this->bell_location,true);
		$criteria->compare('coverage',$this->coverage,true);
		$criteria->compare('portion_specify',$this->portion_specify,true);
		$criteria->compare('monitored',$this->monitored);
		$criteria->compare('type_of_intiation_device',$this->type_of_intiation_device,true);
		$criteria->compare('toid_other',$this->toid_other,true);
		$criteria->compare('no_of_pull_station_per_floor',$this->no_of_pull_station_per_floor);
		$criteria->compare('smoke_detector',$this->smoke_detector);
		$criteria->compare('sd_no_of_unit_per_floor',$this->sd_no_of_unit_per_floor);
		$criteria->compare('sd_integrated',$this->sd_integrated);
		$criteria->compare('heat_detector',$this->heat_detector);
		$criteria->compare('hd_no_of_unit_per_room',$this->hd_no_of_unit_per_room);
		$criteria->compare('hd_integrated',$this->hd_integrated);
		$criteria->compare('power_source_of_detector',$this->power_source_of_detector,true);
		$criteria->compare('psod_other',$this->psod_other,true);
		$criteria->compare('total_detector_per_floor',$this->total_detector_per_floor);
		$criteria->compare('date_last_tested',$this->date_last_tested,true);
		$criteria->compare('inspection_id',$this->inspection_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}